<?php
/**
 * 
 * OrderAction.class.php (前台购物订单)
 *
 * @package      	YOURPHP
 * @author          liuxun QQ:147613338 <admin@yourphp.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.yourphp.cn)
 * @license         http://www.yourphp.cn/license.txt
 * @version        	YourPHP企业网站管理系统 v2.1 2011-03-01 yourphp.cn $
 */
if(!defined("Yourphp")) exit("Access Denied");
class IndexAction extends BaseAction
{
    function _initialize()
    {
	parent::_initialize();

    }


    public function index() {
        if (empty(S('cache_common_index_jingpingw'))) {
            //精品岗位推荐
            $jingpingw = M('gangwei')->where(array('recommend' => 1))->order('listorder asc ,id desc')->limit('8')->select();
            foreach ($jingpingw as $key => $value) {
                $jingpingw[$key]['xmcount'] = M('f_item')->where(array('gwid' => $value['id']))->count();
            }
            S('cache_common_index_jingpingw', $jingpingw, 1000);
        }
        $jingpingw = S('cache_common_index_jingpingw');
        $this->assign('jingpingw', $jingpingw);
        //统计
        //岗位
        if (empty(S('gangwei'))) { 
            $gangwei = M('gangwei')->where(array('status' => 1))->count();
             S('gangwei', $gangwei, 1000);
        }
        $data['gangwei'] = S('gangwei');
        //项目
        if (empty(S('xiangmu'))) { 
            $xiangmu = M('f_item')->where(array('status' => 1))->count();
             S('xiangmu', $xiangmu, 1000);
        }
        $data['xiangmu'] = S('xiangmu');
        //任务
        if (empty(S('renwu'))) { 
            $renwu = M('renwu')->where(array('status' => 1))->count();
             S('renwu', $renwu, 1000);
        }
        $data['renwu'] = S('renwu');
        //微课
        if (empty(S('weike'))) { 
            $weike =  M('weike')->where(array('status' => 1))->count();
             S('weike', $weike, 1000);
        }
        $data['weike'] = S('weike');
        //考试
        if (empty(S('exam'))) { 
            $exam =  json_decode($this->http('http://192.168.1.189/jzexam/index.php?m=Home&c=Api&a=exam_info', array()), 'true');
             S('exam', $exam, 1000);
        }
        $data['exam'] = S('exam');
        //建课
        if (empty(S('jk'))) { 
            $jk =  json_decode($this->http('http://192.168.1.189/jzjk/index.php?m=home&c=count&a=jkcount', array()), 'true');
             S('jk', $jk, 1000);
        }
        $data['jk'] = S('jk');
        //建课
        if (empty(S('user'))) { 
            $user = json_decode($this->http('http://192.168.1.189/user/index.php?m=Home&c=index&a=user_num', array()), 'true');
             S('user', $user, 1000);
        }
        
        $data['user'] = S('user');
        if (empty(S('fangwen'))) { 
            $fangwen = M('browstatis')->sum('num');
             S('fangwen', $fangwen, 1000);
        }
        $data['fangwen'] = S('fangwen') + $data['exam']['visit_num'] + $data['jk']['pv_count'];
        $this->assign('data', $data);
        $this->display();
    }
    
        //首页获取招聘信息
    public function getindexrecruit() {
        if (!empty($_POST['zhuanye'])) {
            $list = M('recruit')->field('comefrom,companyname,salary,title,url,workplace')->where(" zhuanye = '" . $_POST['zhuanye'] . "' ")->order('listorder asc,id desc')->limit(50)->select();
        }
        echo json_encode($list);
    }

}

?>